#include "EquationSolver.h"
#include <limits>

const double eps = numeric_limits<double>::epsilon();

class Func : public Function{
public:
  double operator()(double x){
    return x-tan(x);
  }
  double diff(double x){
    return 1-1/pow(cos(x),2);
  }
};

Func f;

double test1(){
  Newton solver(f, 4.5, eps, 10);
  double result = solver.solve();
  return result;
}

double test2(){
  Newton solver(f, 7.7, eps, 10);
  double result = solver.solve();
  return result;
}


int main(){
  //cout << eps << endl;
  cout << "Newton: The root of function x-tan(x) at 4.5 is " << test1() << endl;
  cout << "Newton: The root of function x-tan(x) at 7.7 is " << test2() << endl;
  return 0;
}
